﻿using Microsoft.VisualStudio.PlatformUI;
using Sasa.QualityTools.CodeAnalysis.Core.Views;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.ViewModels;
using System;
using System.ComponentModel;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views
{
    public partial class CodeAnalysisProgressWindow : DialogWindow, ICodeAnalysisProgressView
    {
        public CodeAnalysisProgressWindow()
        {
            InitializeComponent();
        }


        public void RunOnUIThread(Action action)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                action();
            }));
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            var model = (CodeAnalysisProgressViewModel)DataContext;
            model.CancelCommand.Execute(null);
        }
    }
}
